This assignment will be an exercise in overloading constructors and methods. You will be writing an application.

For this assignment, you will be required to write a base class with several constructors and methods. This class will be inherited. The child classes will also have several constructors and its methods will override the parent class methods.


For this assignment make a base class: Shapes.  
It should have 1 variable (type double): area;
It should have 2 constructors: 
If no parameters are passed area should be -1.0;  
If a parameter is passed, area should be the value.
It should have 2 methods:  computeArea and printSelf;
computeArea should return area.
printSelf should print area.
You next should, by inheritence, create Rectangle and Circle.
Rectangle will inherit area.
Rectangle will have 4 additional datum - integer x1 y1 x2 y2.
Rectangle will by default have area -2.0 x1 = 0, x2 = 0, y1 =0, y2 =0.
Circle will inherit area;
Circle will have 3 additional datum - integer x1 y1 double radius.
Circle will by default hava area -3.0 x1 = 0, y1 = 0, radius = 0.0
Have another constructor for each that overrides this behavior like 
shape did.  
You should have methods computeArea and printSelf, 
in Rectangle and Circle, that override the behavior of the base class.
printSelf should print all instance variable values. 
Implement Shape, Circle, Rectangle and write a main routine that tests
for the following: 
Shapes s = new Shapes();
s.printSelf();
s = new Shapes(13);
s.printSelf();
Rectangle r = new Rectangle();
r.printSelf();
r = new Rectangle(0,0,2,4);
r.computeArea();
r.printSelf();
Circle c = new Circle();
c.printSelf();
c = new Circle(20,20,1.0);
c.computeArea();
c.printSelf();

// polymorphic print
Shapes[] o = new Shapes[3];
o[0]=s;
o[1]=r;
o[2]=c;
System.out.println("\n ***Polymorphic Print***\n");
for(int i = 0; i < 3; i++)
   o[i].printSelf();
Harness Source File
Your output should look like:


 In Shapes area = -1.0

 In Shapes area = 13.0
 
 In Rectangle area = -2.0
 In Rectangle x1, y1 = 0 0
 In Rectangle x2, y2 = 0 0
 
 In Rectangle area = 8.0
 In Rectangle x1, y1 = 0 0
 In Rectangle x2, y2 = 2 4

 In Circle area = -3.0
 In Circle x1, y1 = 0 0
 In Circle radius = 0.0

 In Circle area = 3.14159
 In Circle x1, y1 = 20 20
 In Circle radius = 1.0

 ***Polymorphic Print***

 In Shapes area = 13.0
 
 In Rectangle area = 8.0
 In Rectangle x1, y1 = 0 0
 In Rectangle x2, y2 = 2 4

 In Circle area = 3.14159
 In Circle x1, y1 = 20 20
 In Circle radius = 1.0